package tests 
{
	import controls.TimeBar;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	import helpers.LibraryNames;
	import protocol.dataObjects.TimeBarPositionChange;
	import protocol.dataObjects.TimeBarUserPosition;
	import protocol.dataObjects.User;
	import ru.volgogradetzzz.net.SequentialSwfLoader;
	
	/**
	 * ...
	 * @author Volgogradetzzz
	 */
	public class TimeBarTest extends Sprite 
	{
		
		public function TimeBarTest() 
		{
			var loader:SequentialSwfLoader = SequentialSwfLoader.getInstance();
			loader.addEventListener(Event.COMPLETE, completeHandler);
			loader.load(LibraryNames.INTERFACE, '../src/assets/interface.swf');
			loader.load(LibraryNames.DUMMIES, '../src/assets/dummies.swf');
		}
		
		private function completeHandler(event:Event):void 
		{
			var timeBar:TimeBar = new TimeBar();
			timeBar.x = 100;
			timeBar.y = 100;
			addChild(timeBar);
			
			var user1:User = new User();
			user1.id = 1;
			user1.timeBarPosition = 0 * User.TIME_BAR_POSITION_PRECISION;
			
			var user2:User = new User();
			user2.id = 2;
			user2.timeBarPosition = 0.2 * User.TIME_BAR_POSITION_PRECISION;
			
			timeBar.init(Vector.<User>([user1, user2]));
			
			
			var userPos1:TimeBarUserPosition = new TimeBarUserPosition();
			userPos1.userId = 1;
			userPos1.newPosition = 1 * User.TIME_BAR_POSITION_PRECISION;
			
			var userPos2:TimeBarUserPosition = new TimeBarUserPosition();
			userPos2.userId = 2;
			userPos2.newPosition = 0.7 * User.TIME_BAR_POSITION_PRECISION;
			
			var posChange:TimeBarPositionChange = new TimeBarPositionChange();
			posChange.duration = 5000;
			posChange.userPositions = Vector.<TimeBarUserPosition>([userPos1, userPos2]);
			
			timeBar.start(posChange);
		}
	}
}